'use strict';

describe('Controller: SearchCtrl', function() {

  // load the controller's module
  beforeEach(module('webappApp'));

  var SearchCtrl, scope;

  // Initialize the controller and a mock scope
  beforeEach(inject(function($controller) {
    scope = {};
    SearchCtrl = $controller('SearchCtrl', {
      $scope: scope
    });
  }));

  it('should clear the map before every search', function () {
    var marker = {
      setMap: function (map) {
        this.called = map === null;
      },
      called: false
    };
    scope.markers.push(marker);

    expect(scope.markers.length).toBeTruthy();
    scope.clear();
    expect(scope.markers.length).toBeFalsy();
    expect(marker.called).toBeTruthy();
  });
});
